// import { Form } from 'vant'
import fetch from './fetch'

const bigToastProps = {
	duration: 5000,
	className: 'tkon-toast'
}

export function productDetail(productId) {
	return fetch({
		url: 'insurance/product/productDetail',
		method: 'get',
		params: { productId },
		toastProps: bigToastProps
	})
}
// 去支付
export function goPay(businessId, data) {
	return fetch({
		url: 'insurance/insure/goPay',
		method: 'post',
		data,
		params: { businessId },
		headers: {
			'Content-Type': 'application/json'
		}
	})
}
// 生成订单号
export function createBusiness(params) {
	return fetch({
		url: 'insurance/insure/createBusiness',
		method: 'get',
		params
	})
}

// 获取表单字段
export function queryField(params) {
	return fetch({
		url: 'field/queryField',
		method: 'get',
		params
	})
}

// 获取基本信息
export function information(data) {
	return fetch({
		url: 'field/information',
		method: 'post',
		data
	})
}
// 文件上传
export function uploadFile(data) {
	const fd = new FormData()
	for (let key in data) {
		fd.append(key, data[key])
	}
	return fetch({
		url: 'insurance/uploadFile',
		method: 'post',
		data: fd,
		headers: {
			'Content-Type': 'multipart/form-data'
		}
	})
}
// 校验 发验证码 params {authCode}
export function mobileExchange(params) {
	return fetch({
		url: 'CrmBusiness/mobileExchange',
		method: 'post',
		params
	})
}
// 校验 验验证码 params {authCode, code}
export function checkSms(params) {
	return fetch({
		url: 'CrmBusiness/checkSms',
		method: 'post',
		params
	})
}
// 校验
export function queryLoginUser() {
	return fetch({
		url: 'system/user/queryLoginUser',
		method: 'post'
	})
}
